/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
var vtabber = null;
var bookingTimer = null;

function LabelValue()  {
    this.javaClass = "org.workforce.vo.LabelValue";
    this.text = "";
    this.value = "";
}
function CustomerInfo()  {
    this.javaClass = "org.workforce.vo.CustomerInfo";
    this.customerId = "";
    this.customerName = "";
    this.customerTypeName = "";
    this.billName = "";
}
function BookingBean()
{
    this.javaClass = "limousine.vo.BookingBean";
    this.bookingId = "";
    this.customerId = "";
    this.createBy = "";
    this.createDate = "";
    this.updateBy = "";
    this.updateDate = "";
    this.status = 0;
    this.tableId = "";
    this.carId = "";
    this.driverId = "";
    this.tripType = 0;
    this.fastTrack = 0;
    this.paymentType = 0;
    this.rateCharge = 0;
    this.verifyStatus = 0;
    this.dropOffTime = "";
    this.transportType = 0;
    this.bookingType = 0;
    this.targetType = 0;
    this.fromArea = "";
    this.toArea = "";
    this.guest = "";
    this.atTime = "";
    this.flight = "";    
    this.room = "";
    this.pax = 0;
    this.female = 0;
    this.male = 0;
    this.child = 0;
    this.carReuestType = 0;
    this.fromDate = "";
    this.toDate = "";
    this.vcNo = "";
    this.bookingBy = "";
    this.discountRate = 0.0;
    this.remark = "";
    this.lock = "";
    this.timeOut = "N";
    this.email = "sangsanit@yahoo.com";
}
function loadOptions() {
    loadStatusType();
    loadCarType();
    loadTripType();
    loadDriverType();
    loadTransportType();
    loadRateChargeType();
    loadBookingType();
    loadTargetType();
    loadPaymentType();
    loadFastTrackType();
    loadCarReq();
    loadVerifyType();
}
function loadStatusType() {
    var list = service.getOption("BOOKING_STATUS");
    var i=0;
    var len = $d("status").options.length;
    for( i = len; i >= 0; i--) {
        $d("status").options[i] = null; 
    }
    for( i =0; i < list.size(); i++ ) {
        var txt = list.get(i).text;
        var val = list.get(i).value;
        $d("status").options[i] = new Option(txt, val, false, false);
        
    }
}
function findOption(txt, ops) {
    var i = 0;
    var sops = ops.split(",", ops.length);
    for(i = 0; i < sops.length; i++) {
        if( txt == sops[i] ) {
            return true;
        }
    }
    return false;
}
function selectStatusType(statusType) {
    var list = service.getOption("BOOKING_STATUS");
    var i=0,j=0;
    var len = $d("status").options.length;
    for( i = len; i >= 0; i--) {
        $d("status").options[i] = null; 
    }
    
    for( i = 0, j = 0; i < list.size(); i++ ) {
        var txt = list.get(i).text;
        var val = list.get(i).value;
        if( findOption(txt,statusType) == true ) {
            $d("status").options[j] = new Option(txt, val, false, false);
            j++;
        }
    }
}
function loadTripType() {
    var list = service.getOption('TRIP_TYPE');
    var i=0;
    var len = $d("tripOption").options.length;
    for( i = len; i >= 0; i--) {
        $d("tripOption").options[i] = null; 
    }
    for( i =0; i < list.size(); i++ ) {
        var txt = list.get(i).text;
        var val = list.get(i).value;
        $d("tripOption").options[i] = new Option(txt, val, false, false);
        
    }
}
function loadCarType() {
    var list = service.getCarOption();
    //var list = service.getOption('CAR_TYPE');
    var i=0;
    var len = $d("carOption").options.length;
    for( i = len; i >= 0; i--) {
        $d("carOption").options[i] = null; 
    }
    for( i =0; i < list.size(); i++ ) {
        var txt = list.get(i).text;
        var val = list.get(i).value;
        $d("carOption").options[i] = new Option(txt, val, false, false);
        
    }
}
function loadDriverType() {
    var list = service.getDriverOption();
    var i=0;
    var len = $d("driverOption").options.length;
    for( i = len; i >= 0; i--) {
        $d("driverOption").options[i] = null; 
    }
    for( i =0; i < list.size(); i++ ) {
        var txt = list.get(i).text;
        var val = list.get(i).value;
        $d("driverOption").options[i] = new Option(txt, val, false, false);
        
    }
}
function loadTransportType() {
    var list = service.getOption('TRANSPORT_TYPE');
    var i=0;
    var len = $d("transportOption").options.length;
    for( i = len; i >= 0; i--) {
        $d("transportOption").options[i] = null; 
    }
    for( i =0; i < list.size(); i++ ) {
        var txt = list.get(i).text;
        var val = list.get(i).value;
        $d("transportOption").options[i] = new Option(txt, val, false, false);
        
    }
}
function loadBookingType() {
    var list = service.getOption('BOOKING_TYPE');
    var i=0;
    var len = $d("bookingTypeOption").options.length;
    for( i = len; i >= 0; i--) {
        $d("bookingTypeOption").options[i] = null; 
    }
    for( i =0; i < list.size(); i++ ) {
        var txt = list.get(i).text;
        var val = list.get(i).value;
        $d("bookingTypeOption").options[i] = new Option(txt, val, false, false);
        
    }
}
function loadTargetType() {
    var list = service.getOption('TARGET_TYPE');
    var i=0;
    var len = $d("targetTypeOption").options.length;
    for( i = len; i >= 0; i--) {
        $d("targetTypeOption").options[i] = null; 
    }
    for( i =0; i < list.size(); i++ ) {
        var txt = list.get(i).text;
        var val = list.get(i).value;
        $d("targetTypeOption").options[i] = new Option(txt, val, false, false);
        
    }
}
function loadCarReq() {
    var list = service.getOption('CAR_TYPE');
    var i=0;
    var len = $d("carReq").options.length;
    for( i = len; i >= 0; i--) {
        $d("carReq").options[i] = null; 
    }
    for( i =0; i < list.size(); i++ ) {
        var txt = list.get(i).text;
        var val = list.get(i).value;
        $d("carReq").options[i] = new Option(txt, val, false, false);
        
    }
}
function loadPaymentType() {
    var list = service.getOption('PAYMENT_TYPE');
    var i=0;
    var len = $d("paymentOption").options.length;
    for( i = len; i >= 0; i--) {
        $d("paymentOption").options[i] = null; 
    }
    for( i =0; i < list.size(); i++ ) {
        var txt = list.get(i).text;
        var val = list.get(i).value;
        $d("paymentOption").options[i] = new Option(txt, val, false, false);
        
    }
}
function loadRateChargeType() {
    var list = service.getOption('RATE_CHARGE_TYPE');
    var i=0;
    var len = $d("rateChargeOption").options.length;
    for( i = len; i >= 0; i--) {
        $d("rateChargeOption").options[i] = null; 
    }
    for( i =0; i < list.size(); i++ ) {
        var txt = list.get(i).text;
        var val = list.get(i).value;
        $d("rateChargeOption").options[i] = new Option(txt, val, false, false);
        
    }
}
function loadFastTrackType() {
    var list = service.getOption('FAST_TRACK_TYPE');
    var i=0;
    var len = $d("fastTrackOption").options.length;
    for( i = len; i >= 0; i--) {
        $d("fastTrackOption").options[i] = null; 
    }
    for( i =0; i < list.size(); i++ ) {
        var txt = list.get(i).text;
        var val = list.get(i).value;
        $d("fastTrackOption").options[i] = new Option(txt, val, false, false);
        
    }
}
function loadVerifyType() {
    var list = service.getOption('STATUS_TYPE');
    var i=0;
    var len = $d("verifyOption").options.length;
    for( i = len; i >= 0; i--) {
        $d("verifyOption").options[i] = null; 
    }
    for( i =0; i < list.size(); i++ ) {
        var txt = list.get(i).text;
        var val = list.get(i).value;
        $d("verifyOption").options[i] = new Option(txt, val, false, false);
        
    }
}
function saveBooking() {
    var vk = this.verifyBooking();
    //alert("verify:"+ vk);
    if( vk == false ) {
        return;
    }
    var bean = new BookingBean();
    bean.bookingId = "";
    bean.carReuestType = $d("carOption").value;
    bean.carId = $d("carReq").value;
    bean.driverId = $d("driverOption").value;
    bean.transportType = $d("transportOption").value;
    bean.bookingType = $d("bookingTypeOption").value;
    bean.targetType = $d("targetTypeOption").value;
    bean.fromArea = $d("fromArea").value;
    bean.toArea = $d("toArea").value;
    bean.fromDate = $d("fromTime").value;
    bean.toDate = $d("toTime").value;
    bean.guest = $d("guest").value;
    bean.atTime = $d("time").value;
    bean.flight = $d("filght").value;
    bean.room = $d("room").value;
    bean.pax = parseInt($d("pax").value);
    bean.female = parseInt($d("female").value);
    alert("female:"+ bean.female);
    bean.male = parseInt($d("male").value);
    bean.child = parseInt($d("child").value);
    bean.vcNo = $d("vcno").value;
    bean.discountRate = 0.0;
    bean.tripType = parseInt($d("tripOption").value);
    bean.paymentType = parseInt($d("paymentOption").value);
    bean.fastTrack = parseInt($d("fastTrackOption").value);
    bean.dropOffTime = $d("dropofftime").value;
    bean.rateCharge = parseInt($d("rateChargeOption").value);
    bean.verifyStatus = parseInt($d("verifyOption").value);
    bean.remark = $d('remark').value;
    if( adminMode == true ) {
        bean.customerId = $d('customerId').value;
    } else {
        bean.customerId = customerId;
    }
    var dt = new DateUtil();
    bean.createDate = dt.nowString();
    bean.createBy = userId;
    bean.updateDate = dt.nowString();
    bean.updateBy = userId;
    bean.bookingBy = userId;
    var chk = service.addBooking(bean);
    releaseTab();
    if( chk == "true" ) {
        messageShow("msg=\"Add Booking Success.\";label=\"Close\";onclick=\"messageClose('findBookingByCustomerCallBack()')\";");
    } else {
        messageShow("msg='Can not Add Booking.';label='Close';onclick='messageClose('')';");
    }
}
function editBooking(id) {
    vtabber.tabShow(1);
    var b = service.findBooking(userId, id);
    //alert("in "+ b.lock+ "|status:"+ b.status);
    switch( parseInt(b.status) ) {
        case 1:
            if( b.lock == "N" ) {
                hiddingTab();
                //$d("btnSave").disabled=false;
                $d("btnSave").setAttribute("onClick", "updateBooking()");
                $d("btnSave").setAttribute("value", "Save");
            } else {
                //$d("btnSave").disabled=true;
                $d("btnSave").setAttribute("onClick", "goFront()");
                $d("btnSave").setAttribute("value", "Back");
            }
            break;
        case 2:
            if( b.lock == "N" ) {
                hiddingTab();
                //$d("btnSave").disabled=false;
                $d("btnSave").setAttribute("onClick", "updateBooking()");
                $d("btnSave").setAttribute("value", "Save");
            } else {
                //$d("btnSave").disabled=true;
                $d("btnSave").setAttribute("onClick", "goFront()");
                $d("btnSave").setAttribute("value", "Back");
            }
            break;
        case 3:
            //alert("in 3");
            //$d("btnSave").disabled=true;
            $d("btnSave").setAttribute("onClick", "goFront()");
            $d("btnSave").setAttribute("value", "Back");
            $d("btnReset").disabled=true;
            break;
        case 4:
            //alert("in 4");
            //$d("btnSave").disabled=true;
            $d("btnSave").setAttribute("onClick", "goFront()");
            $d("btnSave").setAttribute("value", "Back");
            $d("btnReset").disabled=true;
            break;
    }
    if( b.timeout == "Y" ) {
        //$d("btnSave").disabled=true;
        $d("btnSave").setAttribute("onClick", "goFront()");
        $d("btnSave").setAttribute("value", "Back");
        $d("btnReset").disabled=true;
    }
    openStatusOption(parseInt(b.status));
    //$d("btnSave").setAttribute("onClick", "updateBooking()");
    $d("bookingId").value = b.bookingId;
    if( parseInt(b.status) == 1 ) {
        $d("status").value = 2;
    } else {
        $d("status").value = b.status;
    }
    $d("carOption").value = b.carReuestType;
    $d("carReq").value = b.carId;
    $d("driverOption").value = b.driverId;
    $d("transportOption").value = b.transportType;
    $d("bookingTypeOption").value = b.bookingType;
    $d("targetTypeOption").value = b.targetType;
    $d("fromArea").value = b.fromArea;
    $d("toArea").value = b.toArea;
    $d("fromTime").value = b.fromDate;
    $d("toTime").value = b.toDate;
    $d("guest").value = b.guest;
    $d("time").value = b.atTime;
    $d("filght").value = b.flight;
    $d("room").value = b.room;
    $d("pax").value = b.pax;
    $d("female").value = b.female;
    $d("male").value = b.male;
    $d("child").value = b.child;
    $d("vcno").value = b.vcNo;

    $d("tripOption").value = b.tripType;
    $d("paymentOption").value = bean.paymentType;
    $d("fastTrackOption").value = bean.fastTrack;
    $d("dropofftime").value = bean.dropOffTime;
    $d("rateChargeOption").value = bean.rateCharge;
    $d("verifyOption").value = bean.verifyStatus;
    
    $d('remark').value = b.remark;
    $d('createBy').value = b.createBy;
    customerId = b.customerId;
    if( adminMode == true ) {
        $d('customerId').value = b.customerId;
    }
}
function updateBooking() {
    var vk = this.verifyBooking();
    if( vk == false ) {
        return;
    }
    var bean = new BookingBean();
    bean.bookingId = $d("bookingId").value;
    bean.status = $d("status").value;
    bean.carReuestType = $d("carOption").value;
    bean.carId = $d("carReq").value;
    bean.driverId = $d("driverOption").value;
    bean.transportType = $d("transportOption").value;
    bean.bookingType = $d("bookingTypeOption").value;
    bean.targetType = $d("targetTypeOption").value;
    bean.fromArea = $d("fromArea").value;
    bean.toArea = $d("toArea").value;
    bean.fromDate = $d("fromTime").value;
    bean.toDate = $d("toTime").value;
    bean.guest = $d("guest").value;
    bean.atTime = $d("time").value;
    bean.flight = $d("filght").value;
    bean.room = $d("room").value;
    bean.pax = $d("pax").value;
    bean.female = parseInt($d("female").value);
    bean.male = parseInt($d("male").value);
    bean.child = parseInt($d("child").value);
    bean.vcNo = $d("vcno").value;
    bean.discountRate = 0.0;
    bean.tripType = parseInt($d("tripOption").value);
    bean.paymentType = parseInt($d("paymentOption").value);
    bean.fastTrack = parseInt($d("fastTrackOption").value);
    bean.dropOffTime = $d("dropofftime").value;
    bean.rateCharge = parseInt($d("rateChargeOption").value);
    bean.verifyStatus = parseInt($d("verifyOption").value);
    bean.remark = $d('remark').value;
    if( adminMode == true ) {
        bean.customerId = $d('customerId').value;
    } else {
        bean.customerId = customerId;
    }
    var dt = new DateUtil();
    bean.createDate = dt.nowString();
    bean.createBy = $d("createBy").value;
    bean.updateDate = dt.nowString();
    bean.updateBy = userId;
    bean.bookingBy = userId;
    var chk = service.editBooking(bean);
    releaseTab();
    if( chk == "true" ) {
        messageShow("msg='<label class=\"message_save\">Save Booking Success.</label>';label='Close';onclick='messageClose('findBookingByCustomerCallBack()')';");
    } else {
        messageShow("msg='Cannot Save Booking.';label='Close';onclick='messageClose('')';");
    }
}
function loadBooking() {
    var ls = null;
    if( adminMode == true ) {
        ls = service.queryBooking(0);
    } else {
        var dt = new DateUtil();
        ls = service.queryBookingByCustomer(0, customerId, dt.nowStringDateOnly());
    }
    var jTable = new JTableBooking();
    jTable.setTableId("tablebooking");
    if( adminMode == true ) {
        jTable.setColumns(["No.", "Time", "Customer", "Guest", "From-To"]);
        jTable.setFields(["row","time","customerName","guest", "area"]);
        jTable.setAlignment("cols[0]='center';cols[1]='center';cols[2]='center';cols[3]='center'");        
    } else {
        jTable.setColumns(["No.", "Time", "Guest", "From-To"]);
        jTable.setFields(["row","time","guest", "area"]);
        jTable.setAlignment("cols[0]='center';cols[1]='center';cols[2]='center'");
    }
    jTable.setEditFunction("edit");
    jTable.setDeleteFunction("remove");
    jTable.setDataId("id");
    jTable.setCount(10);        
    jTable.setOffset(0);
    jTable.setDataPageSize(20);
    jTable.setPageLink("search");
    jTable.setTableHeader();
    jTable.loadData(ls);
        
}
function queryBooking() {
    var ls = null;
    if( adminMode == true ) {
        ls = service.queryBooking(0);
    } else {
        var dt = new DateUtil();
        ls = service.queryBookingByCustomer(0, customerId, dt.nowStringDateOnly());
    }
    var jTable = new JTableBooking();
    jTable.setTableId("tablebooking");
    if( adminMode == true ) {
        jTable.setColumns(["No.", "Time", "Customer", "Guest", "From-To"]);
        jTable.setFields(["row","time","customerName","guest", "area"]);
        jTable.setAlignment("cols[0]='center';cols[1]='center';cols[2]='center';cols[3]='center'");        
    } else {
        jTable.setColumns(["No.", "Time", "Guest", "From-To"]);
        jTable.setFields(["row","time","guest", "area"]);
        jTable.setAlignment("cols[0]='center';cols[1]='center';cols[2]='center'");
    }
    jTable.setEditFunction("edit");
    jTable.setDeleteFunction("remove");
    jTable.setDataId("id");
    jTable.setCount(10);        
    jTable.setOffset(0);
    jTable.setDataPageSize(20);
    jTable.setPageLink("search");
    jTable.setTableHeader();
    jTable.loadData(ls);
        
}
function findBooking(offset,date) {
    vtabber.tabShow(0);
    //autoReload(date);
    //stopReload(date);
    var ls = null;
    if( adminMode == true ) {
        var id = $d('customerId').value;
        if( id != null ) {
            if( id.length == 0 ) {
                ls = service.queryBookingByDate(offset, date);
            } else {
                ls = service.queryBookingByCustomer(offset, id, date);
            }
        } else {
            ls = service.queryBookingByDate(offset, date);
        }
    } else {
        ls = service.queryBookingByCustomer(offset, customerId, date);
    }
    var jTable = new JTableBooking();
    jTable.setTableId("tablebooking");
    if( adminMode == true ) {
        jTable.setColumns(["No.", "Time", "Customer", "Guest", "From-To"]);
        jTable.setFields(["row","time","customerName","guest", "area"]);
        jTable.setAlignment("cols[0]='center';cols[1]='center';cols[2]='center';cols[3]='center'");        
    } else {
        jTable.setColumns(["No.", "Time", "Guest", "From-To"]);
        jTable.setFields(["row","time","guest", "area"]);
        jTable.setAlignment("cols[0]='center';cols[1]='center';cols[2]='center'");
    }
    jTable.setEditFunction("edit");
    jTable.setDeleteFunction("remove");
    jTable.setDataId("id");
    jTable.setCount(10);        
    jTable.setOffset(0);
    jTable.setDataPageSize(20);
    jTable.setPageLink("search");
    jTable.setTableHeader();
    jTable.loadData(ls);
    $d('txtCalendar').value = date;
}
function findBookingByCustomer(offset,customerId,date) {
    vtabber.tabShow(0);
    var ls = service.queryBookingByCustomer(offset, customerId, date);
    var jTable = new JTableBooking();
    jTable.setTableId("tablebooking");
    if( adminMode == true ) {
        jTable.setColumns(["No.", "Time", "Customer", "Guest", "From-To"]);
        jTable.setFields(["row","time","customerName","guest", "area"]);
        jTable.setAlignment("cols[0]='center';cols[1]='center';cols[2]='center';cols[3]='center'");        
    } else {
        jTable.setColumns(["No.", "Time", "Guest", "From-To"]);
        jTable.setFields(["row","time","guest", "area"]);
        jTable.setAlignment("cols[0]='center';cols[1]='center';cols[2]='center'");
    }
    jTable.setEditFunction("edit");
    jTable.setDeleteFunction("remove");
    jTable.setDataId("id");
    jTable.setCount(10);        
    jTable.setOffset(0);
    jTable.setDataPageSize(20);
    jTable.setPageLink("search");
    jTable.setTableHeader();
    jTable.loadData(ls);
}

function findCustomer(offset) {
    var name = $d("customerName").value;
    if( name == null ) name = "";
    var ls = service.findCustomer(offset, name);
    var jTable = new JTable();
    jTable.setTableId("tablecustomer");
    jTable.setColumns(["Name", "Bill Name", "Type"]);
    jTable.setFields(["customerName","billName","customerTypeName"]);
    jTable.setEditFunction("setCustomer");
    jTable.setEditEnable(true);
    jTable.setDeleteFunction("");
    jTable.setDeleteEnable(false);
    jTable.setAlignment("cols[0]='center';cols[1]='center';cols[2]='center'");
    jTable.setDataId("customerId");
    jTable.setCount(10);        
    jTable.setOffset(0);
    jTable.setDataPageSize(20);
    jTable.setPageLink("findCustomer");
    jTable.setTableHeader();
    jTable.loadData(ls);
}
function showCustomerPanel() {
    clearCustomer(); 
    var divcal = document.getElementById("div_customer_panel");
    var width =  window.innerWidth;
    var height = window.innerHeight;
    divcal.style.width = 574+"px";
    divcal.style.height= 560+"px";
    var left2 = ((width/2) - (574/2));
    var top2 = ((height/2) - (560/2));
    divcal.style.borderStyle = "ridge";
    divcal.style.borderWidth = "medium";
    divcal.style.top = top2+"px";
    divcal.style.left = left2+"px";
    divcal.style.visibility = "visible";
    findCustomer(0);
}
function closeCustomerPanel() {
    var divcal = document.getElementById("div_customer_panel");
    divcal.style.visibility = "hidden";
}
function clearCustomer() {
    if( adminMode == true ) {
        $d('customerName').value = "";
        $d('customerId').value = "";
    }
}
function setCustomer(id) {
    var c = service.findCustomerById(id);
    $d('customerName').value = c.customerName;
    $d('customerId').value = c.customerId;
    closeCustomerPanel();
    var txtCalendar = $d('txtCalendar').value;
    var du = new DateUtil();
    if( txtCalendar == null ) {
        txtCalendar = du.nowStringDateOnly();
    } else {
        if( txtCalendar.length == 0 ) {
            txtCalendar = du.nowStringDateOnly();
        } else {
            var txt = txtCalendar.split(" ", 2);
            txtCalendar = txt[0];
        }
    }
    findBooking(0,txtCalendar);
}
function clearBooking() {
    if( adminMode == true ) {
        if( $d('customerId').value == "" ) {
            messageShow("msg='Please select Customer before Booking.';label='Close';onclick=messageClose('')';");
            vtabber.tabShow(0);
        }
    }
    $d('formBooking').reset();
    selectStatusType("REQUEST");
    $d("fromArea").value = "NONE";
    $d("toArea").value = "NONE";
    $d("guest").value = "NONE";
    $d("filght").value = "NONE";
    $d("room").value = "NONE";
    $d("time").value = "00:00";
    $d("pax").value = "0";
    $d("vcno").value = "0";
    $d("remark").value = "NONE";
    $d("dropofftime").value = "NONE";
    $d("btnSave").disabled = false;
    $d('btnSave').setAttribute("value", "Save");
    $d('btnSave').setAttribute("onClick", "saveBooking()");
}
function openStatusOption(status) {
    switch( status ) {
        case 2:
            if( adminMode == true ) {
                selectStatusType("WAIT,ACCEPT,CANCEL");
            } else {
                selectStatusType("WAIT,CANCEL");
            }
            break;
        case 3:
            if( adminMode == true ) {
                selectStatusType("WAIT,ACCEPT,CANCEL");
            } else {
                selectStatusType("WAIT,ACCEPT,CANCEL");
            }
            break;
        case 4:
            if( adminMode == true ) {
                selectStatusType("WAIT,ACCEPT,CANCEL");
            } else {
                selectStatusType("WAIT,ACCEPT,CANCEL");
            }
            break;
    }
}
function verifyBooking() {
    try {
        var v = new Validation();
        v.addField("name='status',label='STATUS',min=1,max=3,type='int',handle='hiligth',release='hdligth'");
        v.addField("name='carOption',label='Car',min=0,max=2,type='int',require=false");
        v.addField("name='driverOption',label='Driver',min=0,max=2,type='int',require=false");
        v.addField("name='transportOption',label='Transport',min=0,max=1,type='int',handle='hiligth',release='hdligth'");
        v.addField("name='bookingTypeOption',label='Booking Type',min=0,max=2,type='int',handle='hiligth',release='hdligth'");
        v.addField("name='targetTypeOption',label='Target Type',min=0,max=2,type='int',handle='hiligth',release='hdligth'");
        v.addField("name='fromArea',label='From Area',min=1,max=50,type='string',handle='hiligth',release='hdligth'");
        v.addField("name='toArea',label='To Area',min=1,max=50,type='string',value='NONE',require=false");
        v.addField("name='fromTime',label='From Time',min=19,max=19,type='datetime',handle='hiligth',release='hdligth'");
        v.addField("name='toTime',label='To Time',min=19,max=19,type='datetime',require=false");
        v.addField("name='guest',label='Guest',min=1,max=50,type='string',handle='hiligth',release='hdligth'");
        v.addField("name='time',label='At Time',type='time',handle='hiligth',release='hdligth'");
        v.addField("name='filght',label='Filght',min=0,max=15,type='string',handle='hiligth',release='hdligth'");
        v.addField("name='room',label='Room',min=0,max=2,type='string',value='NONE',require=false");
        v.addField("name='pax',label='Pax',min=0,max=20,type='int',value=0,require=false");
        v.addField("name='vcno',label='VC No',min=0,max=20,type='string',value='NONE',require=false");
        v.addField("name='remark',label='Remark',min=0,max=254,type='string',value='NONE',require=false");
        var str = v.TrimAll(v.execute());
        if ( str.length == 0 ) {
            return true;
        } else {
            return false;
        }
    } catch(err) {
        alert("Verify Error: "+ err);
        return false;
    }
}
function testenable() {
    verify();
/*
    txtDate = "2011-01-31 20:30:00";
    var re = /^(\d{4})\-(\d{1,2})\-(\d{1,2}) (\d{1,2})\:(\d{1,2})\:(\d{1,2})$/;
    var regs = txtDate.match(re);
    alert(""+regs[1] +" "+regs[2]+" "+regs[3]+" "+regs[4] +" "+regs[5]+" "+regs[6]+"");        
    */
/*
   if( testb == true ) {
       hdligth("status");
       testb = false;
   } else {
   hiligth("status", "tester");
   testb = true;
   }*/
}
function hiligth(name,msg) {
    var div = $d("div_"+name+"_1");
    div.style.borderStyle = "ridge";
    div.style.borderColor = "#ff0000";
    var div2 = $d("div_"+name+"_2");
    div2.style.borderStyle = "ridge";
    div2.style.borderColor = "#ff0000";
    var div3 = $d("div_"+name+"_3");
    div3.style.borderStyle = "ridge";
    div3.style.borderColor = "#ff0000";
    var div4 = $d("div_"+name+"_msg");
    div4.innerHTML = msg;
}
function hdligth(name) {
    var div = $d("div_"+name+"_1");
    div.style.borderStyle = "none";
    var div2 = $d("div_"+name+"_2");
    div2.style.borderStyle = "none";
    var div3 = $d("div_"+name+"_3");
    div3.style.borderStyle = "none";
    var div4 = $d("div_"+name+"_msg");
    div4.innerHTML = "";
}
function hiddingTab() {
    var divcal = document.getElementById("div_hiddingTab");
    var width =  window.innerWidth;
    var left = 0;
    var top = 0;
    //divcal.style.backgroundColor = "#6699CC";
    if( adminMode == false ) {
        divcal.style.height = 128+"px";
    } else {
        divcal.style.height = 172+"px";
    }
    divcal.style.width = width +"px";
    divcal.style.top = left + "px";
    divcal.style.left = top  + "px";
    divcal.style.visibility = "visible";
}
function releaseTab() {
    var divcal = document.getElementById("div_hiddingTab");
    divcal.style.visibility = "hidden";
}
function goFront() {
    var date = new DateUtil();
    findBookingByCustomer(0,customerId,date.nowStringDateOnly());
}
function messageShow(strCond) {
    var div_cal = document.getElementById("div_message");
    var divcal = document.getElementById("message");
    var width =  window.innerWidth;
    var height = window.innerHeight;
    divcal.style.width = 300+"px";
    divcal.style.height= 200+"px";
    var left2 = ((width/2) - (300/2));
    var top2 = ((height/2) - (200/2));
    var left = 0;
    var top = 0;
    div_cal.style.visibility = "visible";
    divcal.style.borderStyle = "ridge";
    divcal.style.backgroundColor = "#999";
    divcal.style.borderWidth = "medium";
    div_cal.style.height = height+"px";
    div_cal.style.width = width +"px";
    div_cal.style.top = left + "px";
    div_cal.style.left = top  + "px";
    divcal.style.top = top2+"px";
    divcal.style.left = left2+"px";
    divcal.style.visibility = "visible";
    var msg = "";
    var onclick = "";
    var label = "";
    eval(strCond);
    $d("message_content").innerHTML = msg;
    if( label != "" ) {
        $d("btnMessage").setAttribute("value", label);
    }
    if( onclick !="" ) {
        $d("btnMessage").setAttribute("onClick", onclick);
    }
}
function messageClose(callBack) {
    var divcal = document.getElementById("div_message");
    divcal.style.visibility = "hidden";
    var divcal2 = document.getElementById("message");
    divcal2.style.visibility = "hidden";
    if( callBack != null ) {
        if( callBack != "" ) {
            eval(callBack);
        }
    }
}
function findBookingByCustomerCallBack() {
    var date = new DateUtil();
    findBookingByCustomer(0,customerId,date.nowStringDateOnly());
}
function fieldFocus(thisForm) {
    if( thisForm.value == "NONE" ) {
        thisForm.value = "";
    } 
}
function fieldBlur(thisForm) {
    if( thisForm.value == "" ) {
        thisForm.value = "NONE";
    } 
}
function autoReload(mdate) {
    var date = new DateUtil();
    if( date.nowStringDateOnly() == mdate ) {
        bookingTimer = setTimeout("findBookingByCustomerCallBack()", 300000);
    }
}
function stopReload(mdate) {
    var date = new DateUtil();
    if( date.nowStringDateOnly() != mdate ) {
        clearTimeout(bookingTimer);
    }
}